#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>

void com()
{
        char op;
        int i,j,k=178;
        int si[7][57]={
          //  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57                                             
            {178,178,178,200,178,178,178,200,178,178,178,200,178,178,178,200,178,178,178,200,200,200,178,178,178,200,178,178,200,200,178,200,178,200,200,200,178,200,178,178,178,200,178,178,200,200,178,178,178,200,178,178,178,200,178,178,178},
            {178,200,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,178,200,200,178,200,178,200,200,200,178,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,178,200,200},
            {178,200,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,178,200,200},
            {178,178,178,200,178,178,178,200,178,178,178,200,178,200,200,200,178,178,200,200,200,200,200,178,200,200,178,200,178,200,178,200,200,178,200,178,200,200,178,178,178,200,178,200,178,200,178,178,200,200,178,178,178,200,178,178,178},
            {200,200,178,200,178,200,200,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,200,200,178,178,200,200,178,200,178,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,178,200,200,200,200,178},
            {200,200,178,200,178,200,200,200,178,200,178,200,178,200,200,200,178,200,200,200,200,200,200,178,200,200,178,200,200,178,178,200,200,178,200,178,200,200,178,200,178,200,178,200,178,200,178,200,200,200,178,200,178,200,200,200,178},
            {178,178,178,200,178,200,200,200,178,200,178,200,178,178,178,200,178,178,178,200,200,200,178,178,178,200,178,200,200,200,178,200,200,200,178,200,200,200,178,200,178,200,178,178,200,200,178,178,178,200,178,200,178,200,178,178,178},
            };
       do
       {
        system("cls");   
       for (i=0; i<7; i++)
       {
            for (j=0; j<57; j++)
                {
                if(si[i][j] == 178)
                {
                printf("%c",k);
                _sleep(5);
                }
                else
                {
                printf(" ");
                _sleep(5);
                }
                }
            printf("\n");
            _sleep(100);
      }
      printf("\n\n\n\n\n\n\t[Pressione Enter]\n\n\n\n\n\n\n\n\nVersion Mega Plus ++ Power Ranger Beta 1\nShow Time. All Rights Reserved");
      
      op = getch();
      
      }
      while(op!='\r');
      
      system("cls");     
     
}

void jogo (void)
{
      int i,j,a=178,b=2,c=207;
      int mat_jogo[20][40]={
       //  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0
          {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},//1
          {1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,1},//2
          {1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,1},//3
          {1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,1},//4
          {1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,1},//5
          {1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,1},//6
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//7
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//8
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//9
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//10
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//11
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//12
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//13
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//14
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//15
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//16
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//17
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//18
          {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//19
          {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},//20
          };
      for(i=0; i<20; i++)
      {
            for(j=0; j<40; j++)
            {
                 if(mat_jogo[i][j]==1)
                 printf("%c",a);
                 else
                 {
                     if(mat_jogo[i][j]==0)
                     printf(" ");
                     else
                     {
                     if(mat_jogo[i][j]==2)
                     printf("%c",b);
                     else
                     printf("%c",c);
                     }
                 }    
            }
      printf("\n");
      }     
      system("pause>>NULL");

}

void esperar(int segundos)  

{  

   clock_t cicloFinal;  

    

   cicloFinal= clock() + segundos * CLOCKS_PER_SEC; /* Calcula o ciclo final de acordo com os segundos passados. */ 

   while (clock() < cicloFinal); /* Para quando o ciclo final e atingido. */ 

 }     

void sair()

{ 

     int x;
     printf(" Issu aeee vai estudar vagaba!!!\n\n");
     for (x=1;x<=3;x++)
     {  
         esperar(1);
          
     }
     
}     


void inst()

{
     
     printf("\n O objetivo %c eliminar todos os invasores! \n Use as teclas <-  -> para  se locomover.\n Use (Espa%co) para atirar.\n\n ",130,135);
     
}

void menu()
{
      int n;
         voltar:
         printf("\t\n\n\n\n\n");
         printf("\t\t 1. Jogar\n" );
         printf("\t\t 2. Instru%c%ces\n",135,228 );
         printf("\t\t 3. Sair\n\n" );
         
         printf("\t\t ***Escolha uma op%c%co***\n\n ",135,198);
         scanf("%d", &n);
         printf("\n");
         system("cls");
         
         
         switch (n) 
         {
                case 1:
                     jogo();
                     break;
                case 2:
                     inst();
                     menu();
                     break;
                case 3:
                     sair();
                     break;          
                default:
                     printf("\t\tOpcao Invalida Tente Novamente!");
                     menu();
                     break;
         }
}

main()
{
        
      com();
      menu();      
      

      exit (0);
}


